<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>已办任务</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
	$(document).ready(function() {
		layui.use(['laypage', 'form','table'], function(){
			var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
			form.render();
			var table = layui.table;
			table.init('taskTable',{limit:30});
			var laypage = layui.laypage;
			laypage.render({elem: 'pageDiv',
				count: ${page.count}, //数据总数，从服务端得到
				curr:${page.pageNo},
				limit:30,
				layout: ['prev', 'page', 'next', 'count'],
				jump: function(obj, first){
				    //obj包含了当前分页的所有参数，比如：
				   // console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
				   // console.log(obj.limit); //得到每页显示的条数
				    
				    //首次不执行
					if(!first){
						$("#firstPage").val(false);
						page(obj.curr,obj.limit);
					}
				}
			});
		});
	});
		function page(n,s){
        	location = '${ctx}/act/task/historic/?pageNo='+n+'&pageSize='+s;
        }
	</script>
</head>
<body>
	<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
		<ul class="layui-tab-title">
			<li><a href="${ctx}/act/task/todo/">待办任务</a></li>
			<li class="layui-this"><a href="${ctx}/act/task/historic/">已办任务</a></li>
			<li><a href="${ctx}/act/task/process/">新建任务</a></li>
		</ul>
	</div>
	<blockquote class="layui-elem-quote quoteBox">
	<form:form id="searchForm" modelAttribute="act" action="${ctx}/act/task/todo/" method="get" class="layui-form">
		<div>
			<div class="layui-inline">
				<label class="layui-form-label">流程类型：&nbsp;</label>
				<div class="layui-input-block">
				<form:select path="procDefKey" class="layui-input">
					<form:option value="" label="全部流程"/>
					<form:options items="${fns:getDictList('act_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">创建时间：</label>
				<div class="layui-input-block">
				<input id="beginDate"  name="beginDate"  type="text" readonly="readonly" maxlength="20" class="layui-input Wdate" style="width:163px;"
				value="<fmt:formatDate value="${act.beginDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});"/>
				</div>
			</div>
				--
			<div class="layui-inline">
				<input id="endDate" name="endDate" type="text" readonly="readonly" maxlength="20" class="layui-input Wdate" style="width:163px;"
				value="<fmt:formatDate value="${act.endDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});"/>
				</div>
			&nbsp;
			<div class="layui-inline">
				<input id="btnSubmit" class="layui-btn search_btn" type="submit" value="查询" />
			</div>
		</div>
	</form:form>
	</blockquote>
	
	<sys:message content="${message}"/>
	<table id="contentTable" class="layui-table" lay-filter="taskTable">
		<thead>
			<tr>
				<th lay-data="{field:'title', minWidth:100}">标题</th>
				<th lay-data="{field:'nowType', minWidth:140}">当前环节</th><%--
				<th>任务内容</th> --%>
				<th lay-data="{field:'taskName', minWidth:100}">流程名称</th>
				<th lay-data="{field:'taskVersion', minWidth:100}">流程版本</th>
				<th lay-data="{field:'buildTime', minWidth:150}">创建时间</th>
				<th lay-data="{field:'todoFlag', minWidth:180}">操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.list}" var="act">
				<c:set var="task" value="${act.histTask}" />
				<c:set var="vars" value="${act.vars}" />
				<c:set var="procDef" value="${act.procDef}" /><%--
				<c:set var="procExecUrl" value="${act.procExecUrl}" /> --%>
				<c:set var="status" value="${act.status}" />
				<tr>
					<td>
						<a class="layui-btn layui-btn-normal layui-btn-xs"
						 href="${ctx}/act/task/form?taskId=${task.id}&taskName=${fns:urlEncode(task.name)}&taskDefKey=${task.taskDefinitionKey}&procInsId=${task.processInstanceId}&procDefId=${task.processDefinitionId}&status=${status}">${fns:abbr(not empty vars.map.title ? vars.map.title : task.id, 60)}</a>
					</td>
					<td>
						<a class="layui-btn layui-btn-normal layui-btn-xs"
						 target="_blank" href="${pageContext.request.contextPath}/act/diagram-viewer?processDefinitionId=${task.processDefinitionId}&processInstanceId=${task.processInstanceId}">${task.name}</a><%--
						<a target="_blank" href="${ctx}/act/task/trace/photo/${task.processDefinitionId}/${task.executionId}">${task.name}</a>
						<a target="_blank" href="${ctx}/act/task/trace/info/${task.processInstanceId}">${task.name}</a> --%>
					</td><%--
					<td>${task.description}</td> --%>
					<td>${procDef.name}</td>
					<td><b title='流程版本号'>V: ${procDef.version}</b></td>
					<td><fmt:formatDate value="${task.endTime}" type="both"/></td>
					<td>
						<a class="layui-btn layui-btn-xs" lay-event="edit"
						 href="${ctx}/act/task/form?taskId=${task.id}&taskName=${fns:urlEncode(task.name)}&taskDefKey=${task.taskDefinitionKey}&procInsId=${task.processInstanceId}&procDefId=${task.processDefinitionId}&status=${status}">详情</a>
					</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<div id="pageDiv" class="pagination layui-elem-field layui-field-title">${page}</div>
</body>
</html>
